package com.yzy.controller;

import com.yzy.dao.AdminDao;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class AdminLonServlet2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String adminid,adminpass;
        AdminDao dao = new AdminDao();
        int result=0;
        //1utf-8
        request.setCharacterEncoding("utf-8");
        //2读取请求体参数
        adminid = request.getParameter("adminid");
        adminpass = request.getParameter("adminpass");
        //3调用dao
        result = dao.longin(adminid,adminpass);
        System.out.println(result);
        //4调用响应对象
        if(result==1){
            response.sendRedirect("/myWeb/patient/find");


        }else{
            response.sendRedirect("/myWeb/adminlongin_error.html");
        }
    }
}
